package com.jianyun.jyzs.presenter;

import android.util.Log;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.jianyun.jyzs.bean.User;
import com.jianyun.jyzs.model.ContactModel;
import com.jianyun.jyzs.model.imdoel.IContactModel;
import com.jianyun.jyzs.view.iview.IContactFragmentView;

import java.util.List;

/**
 * Created by yangshijun on 2018/10/9.
 */

public class ContactPresneter extends MvpBasePresenter<IContactFragmentView> {

    public void loadContact(String enterpriseCode, String userId, String pageIndex) {
        if (!isViewAttached()) return;
        getView().showLoading();
        ContactModel.getInstance().getContact(enterpriseCode, userId, pageIndex, new IContactModel.OnLoadContactLisener() {

            @Override
            public void onSuccess(List<User> list) {
                Log.e("err", "通讯录：" + list.size());
                getView().loadContactSuccess(list);
            }

            @Override
            public void onFailed(String msg) {
                getView().loadFailed(msg);

            }

            @Override
            public void setToal(int pageToal, int indexPage) {
                getView().setPageCut(pageToal,indexPage);
            }

            @Override
            public void onNoLoadMore(boolean isMore) {
                getView().onLoadMore(isMore);
            }
        });

    }

    public void getMoreContact(String enterpriseCode, String userId, int pageIndex,int total){
        if (!isViewAttached()) return;
        getView().showLoading();
        ContactModel.getInstance().onLoadMoreContact(enterpriseCode, userId, pageIndex, total, new IContactModel.OnLoadContactLisener() {
            @Override
            public void onSuccess(List<User> list) {
                Log.e("err", "通讯录：" + list.size());
                getView().loadContactSuccess(list);
            }

            @Override
            public void onFailed(String msg) {
                getView().loadFailed(msg);

            }

            @Override
            public void setToal(int pageToal, int indexPage) {
                getView().setPageCut(pageToal,indexPage);
            }

            @Override
            public void onNoLoadMore(boolean isMore) {
                getView().onLoadMore(isMore);
            }
        });
    }


}
